package com.breaking.second.entity;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;

import java.util.List;

import lombok.Data;

//获取返回的信息
@Data
public class PageableEntity {
    private int current;
    private int size;
    private int total;
    private Object records;

    public <T> T to(Class<T> c) {
        if (records instanceof JSONObject da) {
            return da.to(c);
        }
        return null;
    }

    public <T> List<T> toList(Class<T> itemClass) {
        if (records instanceof JSONArray da) {
            return da.toList(itemClass);
        }
        return null;
    }
}
